//
//  OrderStatusVC.m
//  QoilPublic
//
//  Created by SunChao on 17/9/11.
//  Copyright © 2017年 杨凯. All rights reserved.
//

#import "OrderStatusVC.h"
#import "OrderStatusCell.h"
#import "SheetView.h"
#import "EvaluationCell.h"
#import "GDGInfiniteScrollView.h"
#import "CustomTableView.h"
#import "OrderListModel.h"
@interface OrderStatusVC ()<UIScrollViewDelegate>

@property (nonatomic,strong)SheetView *sheetView;
@property (nonatomic,strong)NSMutableArray *dataArr;
@end

@implementation OrderStatusVC
- (id)init{
    self = [super init];
    if (self) {
        
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"订单状态";
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.clipsToBounds = YES;
    //初始化对象
     //NSArray *statusArr = @[@(6),@(2),@(3),@(4)];
    [self requestData];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    
    //去掉透明后导航栏下边的黑边
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    //半透明
    self.navigationController.navigationBar.translucent = NO;
    
}

- (void)createUIWithData:(NSArray *)array{
    
    GDGInfiniteScrollView *  scrollView = [[GDGInfiniteScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-StatusBarHeight) dataSource:array];
    
    [self.view addSubview:scrollView];

}
- (void)requestData{

    NSString *url = [QParamService urlWithAction:@"getMsgOrderList"];
    
    NSDictionary *para = [QParamService gainOrderInfoWithStart:@"1" pageSize:KpageSize];
    [QViewUtility showMBHudToView:self.view hideBg:YES];
    [QViewUtility disMissNoRecordInVC:self];
    [QViewUtility disMissNoNetWorkInVC:self];
    [[QHttpManager sharedManager] POST:url parameterMD5:para completion:^(NSData *data, NSDictionary *dict, NSError *error) {

        [QViewUtility hideMBHudToView:self.view];
        if(error){
            if([QUserInfo sharedInfo].isHaveNetWork == NO){
            }
            return ;
        }
        QBaseModel *basModel = [QBaseModel objectFromDict:dict];
        if([basModel.result isEqualToString:@"success"]){
            
            NSLog(@"------%@",basModel.result);
            _dataArr = [NSMutableArray new];
            _dataArr = [OrderListModel mj_objectArrayWithKeyValuesArray:[basModel.items objectForKey:@"list"]];
            
            if(_dataArr.count == 0){
                
                [QViewUtility showNoRecordViewInView:self.view Title:@"没有任何消息哦~"];
                
            }else{

                
                [self createUIWithData:(_dataArr)];
                
            }
            
        }else{
            [QViewUtility showAlertViewWithImage:[UIImage imageNamed:@"cry_image"] content:basModel.errMsg btnTitle:showAlertBtnTitle type:1 myBlock:^{}];
        }
    }];
}


@end
